package cn.tang.tframe.sdm.web.shiro.session;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.SessionContext;
import org.apache.shiro.session.mgt.SessionFactory;
import org.springframework.beans.factory.annotation.Value;

/**
 * 为了生成appSession而写的factory
 * 
 * @author tanghc
 *
 */
public class AppSessionFactory implements SessionFactory {

	@Value("${app.session.expire.ms}")
	private long timeout;
//	@Value("${app.session.login.expire.sec}")
//	private long loginTimeoutSec;

	public Session createSession(SessionContext initData) {
		if (initData != null) {
			String host = initData.getHost();
			if (host != null) {
				AppSession appSession = new AppSession(host, timeout);
//				appSession.setLoginTimeoutSec(timeout);
				return appSession;
			}
		}
		AppSession appSession = new AppSession(timeout);
//		appSession.setLoginTimeoutSec(loginTimeoutSec);
		return appSession;
	}
}
